package com.jg.utils.reflex.classes;

import com.jg.utils.reflex.en.Session;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Constructor;

public class ObjectTest {

    @Test
    public void testObject(){
        Session session1 = Session.get();
        Session session2 = Session.get();
        System.out.println(session1 == session2);

    }

    /**
     * 破坏单例模式
     * @throws Exception
     */

    @Test
    public  void testConstructorNewInstance() throws Exception{
        Class<Session> sessionClass = Session.class;
        Constructor<Session> declaredConstructor = sessionClass.getDeclaredConstructor();
        declaredConstructor.setAccessible(true);
        Session session1 = declaredConstructor.newInstance();
        Session session2 = declaredConstructor.newInstance();
        System.out.println(session1 == session2);

    }


}
